#ifndef DOUBANFRAME_P_H_
#define DOUBANFRAME_P_H_

#include <QObject>
#include <QButtonGroup>
#include "ui_DoubanFrame.h"

class QLabel;
class QMovie;
class QPushButton;
class QMouseEvent;
class QPropertyAnimation;

namespace Douban
{
	class DoubanFrame;
	class DoubanFramePrivate : QObject
	{
		Q_OBJECT
		Q_DISABLE_COPY(DoubanFramePrivate)

		const static QString Search_URL;
		enum FrameState
		{
			DHome=1, DMail
		};

		public:
			~DoubanFramePrivate();
		protected:
			bool eventFilter(QObject* w,QEvent* e);
		private:
			DoubanFramePrivate(DoubanFrame* p);

			Ui::DoubanFrame ui;
			DoubanFrame* m_pImpl;

			bool b_inited;
			bool b_isShowingLoading;
			int e_state;
			QButtonGroup		m_btnGroup;
			QPropertyAnimation* m_stateAnimation;
			QPropertyAnimation* m_stateAnimation2;

			QWidget*		errorWidget;
			QLabel*			errorLabel;
			QPushButton*	errorBtn;

			QLabel* m_unreadMailCountLabel;

			QMovie* m_loadingMovie;

			QWidget* m_miniblogWidget;
			QWidget* m_mailWidget;

			QWidget* widgetOfState(int state);
			void showError(const QString&,const QString&);
			void showLoading();
			void hideLoading();
			void setContents(QWidget* miniblog,QWidget* mail);
			void hideInputFrame(bool success);
		private slots:
			void errorBtnPressed();

			void changeState(int state);
			void animationFinished(){ui.toolBarFrame->setEnabled(true);}

			void toogleSearchFrame();
			void goSearch();

			void visitDouban();
		friend class DoubanFrame;
	};
}

#endif /* DOUBANFRAME_P_H_ */
